home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1518 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: telepost.no!usenet
  2. From: Carsten Arnholm <ca@sesam.dnv.no>
  3. Newsgroups: comp.lang.c++,comp.lang.fortran
  4. Subject: Re: Calling Fortran in C++
  5. Date: 11 Jan 1996 13:59:19 GMT
  6. Organization: DNV
  7. Message-ID: <4d353n$sk1@nms.telepost.no>
  8. References: <4cr87l$794$1@mhafc.production.compuserve.com>    <4crisr$v3u@odin.sunquest.com> <4ctro6$28n@nms.telepost.no> <o9thgy5krp7.fsf@aqua2.marina.unit.no>
  9. NNTP-Posting-Host: hugin.sesam.dnv.no
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1 (Windows; I; 32bit)
  14.  
  15. jenhel@stud.unit.no (Jens Helmers) wrote:
  16. >Do MS VC++/Powerstation handle arguments of general user defined 
  17. >F90-types with or without storage association? 
  18. >What about F90 pointers?
  19. >
  20. >
  21. >TYPE a
  22. >  .......
  23. >END TYPE a
  24. >
  25. >
  26. >TYPE b
  27. >  SEQUENCE
  28. >  .......
  29. >END TYPE b
  30. >
  31. >
  32. >Jens Helmers,
  33. >jenhel@marin.unit.no
  34.  
  35.  
  36. I do not have any practical experience with F90, only F77 so
  37. I don't know the answer to this (interesting) question.
  38.  
  39. In my F90 book (Fortran 90 Explained, by Metcalf & Reid), the
  40. SEQUENCE attribute is listed as "Deprecated". I guess this means
  41. you should be carful in using it (is there a more standard way?).
  42.  
  43. I guess the F90 TYPE is a close match to the C/C++ struct. 
  44. In fortran 77 there is only one type that has some resemblance
  45. with C/C++ structs, namely the CHARACTER type (it has a "char*"
  46. pointer and a length). It is the CHARACTER type which has a 
  47. tendency to cause problems when you want to port mixed language
  48. programs to new platforms.
  49.  
  50. My hope would be that you could declare a class/struct in C++
  51. with the same memory layout as the F90 user defined type. Perhaps
  52. you need something like the SEQUENCE attribute to control the 
  53. memory layout of the F90 type.
  54.  
  55. If you could do that, I guess you could pass C/C++ structs 
  56. as a "call by reference" parameter, and receive it as a F90 user
  57. defined type in FORTRAN. Whether the different F90 compilers have
  58. the same idea about passing such parameters, I don't know.
  59. Maybe some compilers would require a "call by value" parameter, or
  60. something more isoteric ?
  61.  
  62. I guess F90 pointers can be passed as long as the F90 type it points
  63. to has a compatible C/C++ struct defined in the C/C++ code ? Only in 
  64. that case, dereferencing the pointer would be meaningful.
  65. Or perhaps this is not so easy ?
  66.  
  67. It would be interesting to hear if someone have successfully done
  68. these things, as I might need to do some F90 stuff one day.
  69.  
  70.  
  71. Carsten Arnholm
  72. ca@sesam.dnv.no
  73.  
  74.